import { z } from 'zod';

export const DeptSchema = z.object({
  parentId: z.number().int(),
  deptName: z.string().min(1, { message: '部门名称不能为空' }),
  orderNum: z.number().min(0, { message: '排序不能小于0' }),
  status: z.enum(['0', '1'], { message: '状态值只能为0或1' }),
});

export const RoleSchema = z.object({
  roleName: z.string().min(1, { message: '角色名称不能为空' }),
  roleKey: z.string().min(1, { message: '权限字符不能为空' }),
  roleSort: z.number().min(0, { message: '排序不能小于0' }),
  status: z.enum(['0', '1'], { message: '状态值只能为0或1' }),
});

export const MenuSchema = z.object({
  menuName: z.string().min(1, { message: '菜单名称不能为空' }),
  orderNum: z.number().min(0, { message: '排序不能小于0' }),
  visible: z.enum(['0', '1'], { message: '状态值只能为0或1' }),
});

export const PostSchema = z.object({
  postName: z.string().min(1, { message: '岗位名称不能为空' }),
  postCode: z.string().min(1, { message: '岗位编码不能为空' }),
  postSort: z.number().min(0, { message: '排序不能小于0' }),
  status: z.enum(['0', '1'], { message: '状态值只能为0或1' }),
});

export const UserSchema = z.object({
  userName: z.string().min(1, { message: '用户名称不能为空' }),
  email: z.string().email({ message: '邮箱格式不正确' }),
  phonenumber: z.string().min(11, { message: '手机号码不能小于11位' }),
  status: z.enum(['0', '1'], { message: '状态值只能为0或1' }),
});

export const UserSchema2 = UserSchema.partial({
  email: true,
  phonenumber: true,
});